package org.apache.ibatis.demo;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.demo.bean.User;

import java.util.List;

/**
 * UserDao
 *
 * @author zhaohui
 * @date 2019/8/27 21:01
 */
public interface UserDao {

    /**
     * insert
     *
     * @param user user
     * @return count
     */
    int insert(User user);

    /**
     * 批量插入
     *
     * @param users
     * @return
     */
    int batchInsert(List<User> users);

    /**
     * getById
     *
     * @param userId id
     * @return user
     */
    User getById(int userId);

    /**
     * select all
     *
     * @return users
     */
    List<User> selectAll();

    /**
     * max id
     *
     * @return last id
     */
    int lastId();

    /**
     * getByUserNameAndIdCard
     *
     * @param userName user name
     * @param idCard   id card
     * @return users
     */
    List<User> getByUserNameAndIdCard(@Param("userName") String userName, @Param("idCard") String idCard);

    /**
     * 查询只读结果
     *
     * @param id
     * @return
     */
    User getOnlyReadResult(@Param("id") Long id);

    /**
     * 分页查询（逻辑分页）
     *
     * @param maxId
     * @param rowBounds
     * @return
     */
    List<User> queryForPage(Long maxId, RowBounds rowBounds);

    List<User> queryForPage1(Long maxId);
}
